﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace StockTradTest
{
    public class TextRecord
    {
        static readonly string path = Path.Combine(Base.Root, "record.txt");
        public static void Record(string str,bool isNew = false)
        {
            if(!str.EndsWith("\n"))
            {
                str += "\n";
            }
            FileStream fs;
            if (isNew)
            {
                fs = new FileStream(path, FileMode.Create);
            }
            else
            {
                fs = new FileStream(path, FileMode.Append);
            }
            //获得字节数组
            byte[] data = System.Text.Encoding.Default.GetBytes(str);
            //开始写入
            fs.Write(data, 0, data.Length);
            //清空缓冲区、关闭流
            fs.Flush();
            fs.Close();

        }
        public static void OpenRecord()
        {
            System.Diagnostics.Process.Start("notepad.EXE",path);
        }
    }
}
